<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>基于区域生长的分割 | 荒岛</title><meta name="author" content="Fi9zero"><meta name="copyright" content="Fi9zero"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="基于区域生长的分割 🧩 一、整体流程概述本程序实现了一个 基于法线和曲率的区域生长点云分割算法，主要步骤如下：  加载点云 估计法线 可选：Z轴方向裁剪（直通滤波） 区域生长分割（利用法线平滑性和曲率） 输出聚类数量 + 可视化结果 打印时间与内存消耗   ✅ 适用于：物体分割、场景理解、点云去噪、工业检测等任务。   🔧 二、核心模块解析   模块 作用    pcl::NormalEsti">
<meta property="og:type" content="article">
<meta property="og:title" content="基于区域生长的分割">
<meta property="og:url" content="https://ckyfi9zero.github.io/2025/08/05/2025-08-05-%E5%9F%BA%E4%BA%8E%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E7%9A%84%E5%88%86%E5%89%B2/index.html">
<meta property="og:site_name" content="荒岛">
<meta property="og:description" content="基于区域生长的分割 🧩 一、整体流程概述本程序实现了一个 基于法线和曲率的区域生长点云分割算法，主要步骤如下：  加载点云 估计法线 可选：Z轴方向裁剪（直通滤波） 区域生长分割（利用法线平滑性和曲率） 输出聚类数量 + 可视化结果 打印时间与内存消耗   ✅ 适用于：物体分割、场景理解、点云去噪、工业检测等任务。   🔧 二、核心模块解析   模块 作用    pcl::NormalEsti">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ckyfi9zero.github.io/image/avatar.jpg">
<meta property="article:published_time" content="2025-08-05T06:04:06.000Z">
<meta property="article:modified_time" content="2025-08-05T06:06:23.536Z">
<meta property="article:author" content="Fi9zero">
<meta property="article:tag" content="c++">
<meta property="article:tag" content="PCL">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://ckyfi9zero.github.io/image/avatar.jpg"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "基于区域生长的分割",
  "url": "https://ckyfi9zero.github.io/2025/08/05/2025-08-05-%E5%9F%BA%E4%BA%8E%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E7%9A%84%E5%88%86%E5%89%B2/",
  "image": "https://ckyfi9zero.github.io/image/avatar.jpg",
  "datePublished": "2025-08-05T06:04:06.000Z",
  "dateModified": "2025-08-05T06:06:23.536Z",
  "author": [
    {
      "@type": "Person",
      "name": "Fi9zero",
      "url": "https://ckyfi9zero.github.io"
    }
  ]
}</script><link rel="shortcut icon" href="/image/favicon.ico"><link rel="canonical" href="https://ckyfi9zero.github.io/2025/08/05/2025-08-05-%E5%9F%BA%E4%BA%8E%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E7%9A%84%E5%88%86%E5%89%B2/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '基于区域生长的分割',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/pig.css"><link rel="stylesheet" href="https://npm.elemecdn.com/ethan4116-blog/lib/css/plane_v2.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(/image/per%20page.jpg);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">荒岛</span></a><a class="nav-page-title" href="/"><span class="site-name">基于区域生长的分割</span><span class="site-name"><i class="fa-solid fa-circle-arrow-left"></i><span>  返回首页</span></span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">基于区域生长的分割</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-08-05T06:04:06.000Z" title="发表于 2025-08-05 14:04:06">2025-08-05</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-08-05T06:06:23.536Z" title="更新于 2025-08-05 14:06:23">2025-08-05</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/PCL/">PCL</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h1 id="基于区域生长的分割"><a href="#基于区域生长的分割" class="headerlink" title="基于区域生长的分割"></a>基于区域生长的分割</h1><hr>
<h2 id="🧩-一、整体流程概述"><a href="#🧩-一、整体流程概述" class="headerlink" title="🧩 一、整体流程概述"></a>🧩 一、整体流程概述</h2><p>本程序实现了一个 <strong>基于法线和曲率的区域生长点云分割算法</strong>，主要步骤如下：</p>
<ol>
<li><strong>加载点云</strong></li>
<li><strong>估计法线</strong></li>
<li><strong>可选：Z轴方向裁剪（直通滤波）</strong></li>
<li><strong>区域生长分割（利用法线平滑性和曲率）</strong></li>
<li><strong>输出聚类数量 + 可视化结果</strong></li>
<li><strong>打印时间与内存消耗</strong></li>
</ol>
<blockquote>
<p>✅ 适用于：物体分割、场景理解、点云去噪、工业检测等任务。</p>
</blockquote>
<hr>
<h2 id="🔧-二、核心模块解析"><a href="#🔧-二、核心模块解析" class="headerlink" title="🔧 二、核心模块解析"></a>🔧 二、核心模块解析</h2><table>
<thead>
<tr>
<th>模块</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td><code>pcl::NormalEstimation</code></td>
<td>为每个点计算法向量，是区域生长的基础</td>
</tr>
<tr>
<td><code>pcl::PassThrough</code></td>
<td>可选地去除远处或过近的无关点（如背景或传感器噪声）</td>
</tr>
<tr>
<td><code>pcl::RegionGrowing</code></td>
<td>核心分割算法，基于法线夹角和曲率增长区域</td>
</tr>
<tr>
<td><code>CloudViewer</code></td>
<td>简单可视化工具，自动为不同聚类分配颜色</td>
</tr>
</tbody></table>
<hr>
<h2 id="⚙️-三、关键参数说明"><a href="#⚙️-三、关键参数说明" class="headerlink" title="⚙️ 三、关键参数说明"></a>⚙️ 三、关键参数说明</h2><table>
<thead>
<tr>
<th>参数</th>
<th>含义</th>
<th>推荐值</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td><code>-kn 50</code></td>
<td>法线估计邻居数</td>
<td>20~100</td>
<td>太小：噪声大；太大：细节模糊</td>
</tr>
<tr>
<td><code>-bc 0/1</code></td>
<td>是否启用裁剪</td>
<td>0（否）或 1（是）</td>
<td>控制是否进行 <code>z</code> 轴过滤</td>
</tr>
<tr>
<td><code>-fc 10.0</code></td>
<td>远裁剪距离</td>
<td>根据场景设置</td>
<td>如只保留 10 米内点</td>
</tr>
<tr>
<td><code>-nc 0.0</code></td>
<td>近裁剪距离</td>
<td>避免传感器附近噪声</td>
<td>如 0.5m</td>
</tr>
<tr>
<td><code>-st 30</code></td>
<td>平滑角阈值（°）</td>
<td>10~45°</td>
<td>法线夹角小于该值则合并，<strong>控制分割粗细</strong></td>
</tr>
<tr>
<td><code>-ct 0.05</code></td>
<td>曲率阈值</td>
<td>0.01~0.1</td>
<td>曲率高于此值认为是边界（角、边缘）</td>
</tr>
</tbody></table>
<blockquote>
<p>⚠️ 注意：<code>SmoothnessThreshold</code> 需从<strong>角度转为弧度</strong>（<code>/180*M_PI</code>），否则无效！</p>
</blockquote>
<hr>
<h2 id="📈-四、性能监控功能"><a href="#📈-四、性能监控功能" class="headerlink" title="📈 四、性能监控功能"></a>📈 四、性能监控功能</h2><ul>
<li><strong>时间统计</strong>：分别记录：<ol>
<li>文件加载耗时</li>
<li>法线估计耗时</li>
<li>区域生长耗时</li>
</ol>
</li>
<li><strong>内存监控（Linux）</strong>：<ul>
<li>读取 <code>/proc/self/status</code> 中的 <code>VmRSS</code> 字段</li>
<li>输出当前物理内存占用（KB &#x2F; MB）</li>
</ul>
</li>
<li>便于分析算法效率和资源消耗</li>
</ul>
<hr>
<h2 id="🎨-五、可视化特点"><a href="#🎨-五、可视化特点" class="headerlink" title="🎨 五、可视化特点"></a>🎨 五、可视化特点</h2><ul>
<li>使用 <code>CloudViewer</code> 实现一键可视化</li>
<li><code>reg.getColoredCloud()</code> 自动生成<strong>彩色点云</strong>：<ul>
<li>每个聚类分配一种颜色</li>
<li>不同物体清晰可辨</li>
</ul>
</li>
<li>用户可通过鼠标旋转、缩放查看结果</li>
</ul>
<hr>
<h2 id="🌱-六、区域生长原理简述"><a href="#🌱-六、区域生长原理简述" class="headerlink" title="🌱 六、区域生长原理简述"></a>🌱 六、区域生长原理简述</h2><blockquote>
<p><strong>思想</strong>：从种子点出发，逐步将“相似”的邻近点加入同一区域。</p>
</blockquote>
<p>判断“相似”的两个标准：</p>
<ol>
<li><strong>法线一致性</strong>（平滑性）：<ul>
<li>两邻点法线夹角 &lt; <code>SmoothnessThreshold</code></li>
<li>保证表面平滑连续</li>
</ul>
</li>
<li><strong>曲率大小</strong>：<ul>
<li>低曲率点更可能属于同一平面或曲面</li>
<li>高曲率点（如边角）不参与合并</li>
</ul>
</li>
</ol>
<blockquote>
<p>✅ 优势：能保留曲面细节，适合不规则物体分割<br>❌ 缺点：对法线质量敏感，噪声大时效果差</p>
</blockquote>
<hr>
<h2 id="💾-七、输出结果"><a href="#💾-七、输出结果" class="headerlink" title="💾 七、输出结果"></a>💾 七、输出结果</h2><ul>
<li><strong>控制台输出</strong>：<ul>
<li>各阶段耗时</li>
<li>聚类总数</li>
<li>第一个聚类的点数</li>
<li>内存使用</li>
</ul>
</li>
<li><strong>可视化窗口显示</strong>：<ul>
<li>彩色分割结果（不同簇不同颜色）</li>
</ul>
</li>
</ul>
<blockquote>
<p>📝 示例输出：</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">Loading pcd file takes (seconds): 0.12</span><br><span class="line">Estimating normal takes (seconds): 0.87</span><br><span class="line">Region growing takes (seconds): 1.34</span><br><span class="line">Number of clusters: 6</span><br><span class="line">First cluster has 1245 points.</span><br><span class="line"></span><br><span class="line">--- Memory Usage (Linux) ---</span><br><span class="line">Current RSS Memory: 185234 KB (180.89 MB)</span><br></pre></td></tr></table></figure>

<hr>
<h2 id="🛠️-八、可改进方向（进阶建议）"><a href="#🛠️-八、可改进方向（进阶建议）" class="headerlink" title="🛠️ 八、可改进方向（进阶建议）"></a>🛠️ 八、可改进方向（进阶建议）</h2><table>
<thead>
<tr>
<th>改进方向</th>
<th>实现方式</th>
</tr>
</thead>
<tbody><tr>
<td>添加点云下采样</td>
<td>使用 <code>VoxelGrid</code> 降低密度，提升速度</td>
</tr>
<tr>
<td>支持彩色点云</td>
<td>改用 <code>PointXYZRGB</code> 并融合颜色相似性</td>
</tr>
<tr>
<td>多尺度分割</td>
<td>调整 <code>SmoothnessThreshold</code> 实现粗&#x2F;细分割</td>
</tr>
<tr>
<td>自动参数选择</td>
<td>基于点云密度或统计特征动态设置阈值</td>
</tr>
<tr>
<td>保存聚类结果</td>
<td>将每个 <code>cluster</code> 保存为独立 <code>.pcd</code> 文件</td>
</tr>
<tr>
<td>使用 <code>PCLVisualizer</code> 替代 <code>CloudViewer</code></td>
<td>更灵活控制视图、灯光、标注</td>
</tr>
</tbody></table>
<hr>
<h2 id="✅-带详细注释的代码（右侧为解释）"><a href="#✅-带详细注释的代码（右侧为解释）" class="headerlink" title="✅ 带详细注释的代码（右侧为解释）"></a>✅ 带详细注释的代码（右侧为解释）</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;iostream&gt;</span>                             <span class="comment">// 标准输入输出</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;vector&gt;</span>                               <span class="comment">// 动态数组，用于存储聚类索引</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/point_types.h&gt;</span>                    <span class="comment">// 点类型定义，如 PointXYZ</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/io/pcd_io.h&gt;</span>                      <span class="comment">// 读写 .pcd 文件</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/search/search.h&gt;</span>                  <span class="comment">// 通用搜索接口</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/search/kdtree.h&gt;</span>                  <span class="comment">// KdTree 加速邻域搜索</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/features/normal_3d.h&gt;</span>             <span class="comment">// 法线估计模块</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/visualization/cloud_viewer.h&gt;</span>     <span class="comment">// 简单点云可视化工具</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/filters/passthrough.h&gt;</span>            <span class="comment">// 直通滤波器（裁剪范围）</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/segmentation/region_growing.h&gt;</span>    <span class="comment">// 区域生长分割算法</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/console/print.h&gt;</span>                  <span class="comment">// PCL 日志输出宏（PCL_INFO, PCL_ERROR）</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/console/parse.h&gt;</span>                  <span class="comment">// 命令行参数解析</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/console/time.h&gt;</span>                   <span class="comment">// 时间测量支持</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 替代 Windows 平台的内存监控（windows.h + psapi.h）</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;sys/resource.h&gt;</span>  <span class="comment">// 用于获取 Linux 下内存使用（VmRSS）</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;unistd.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;fstream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;sstream&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> pcl::console;  <span class="comment">// 使用 PCL 控制台命名空间，简化 parse_argument 等调用</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// Linux 下获取当前进程内存使用（单位：KB）</span></span><br><span class="line"><span class="function"><span class="type">long</span> <span class="title">getMemoryUsage</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="function">std::ifstream <span class="title">file</span><span class="params">(<span class="string">&quot;/proc/self/status&quot;</span>)</span></span>;   <span class="comment">// 读取当前进程状态</span></span><br><span class="line">    std::string line;</span><br><span class="line">    <span class="keyword">while</span> (std::<span class="built_in">getline</span>(file, line)) &#123;</span><br><span class="line">        <span class="keyword">if</span> (line.<span class="built_in">compare</span>(<span class="number">0</span>, <span class="number">6</span>, <span class="string">&quot;VmRSS:&quot;</span>) == <span class="number">0</span>) &#123; <span class="comment">// 查找 &quot;VmRSS:&quot; 行（物理内存占用）</span></span><br><span class="line">            <span class="function">std::istringstream <span class="title">iss</span><span class="params">(line)</span></span>;</span><br><span class="line">            std::string key;</span><br><span class="line">            <span class="type">long</span> value;</span><br><span class="line">            iss &gt;&gt; key &gt;&gt; value;                 <span class="comment">// 解析出数值</span></span><br><span class="line">            <span class="keyword">return</span> value;                        <span class="comment">// 返回内存使用量（KB）</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 打印内存信息（Linux 版）</span></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">PrintMemoryInfo</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="type">long</span> mem_kb = <span class="built_in">getMemoryUsage</span>();</span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;\n--- Memory Usage (Linux) ---&quot;</span> &lt;&lt; std::endl;</span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;Current RSS Memory: &quot;</span> &lt;&lt; mem_kb &lt;&lt; <span class="string">&quot; KB (&quot;</span> </span><br><span class="line">              &lt;&lt; (mem_kb / <span class="number">1024.0</span>) &lt;&lt; <span class="string">&quot; MB)&quot;</span> &lt;&lt; std::endl;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">char</span>** argv)</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 检查命令行参数是否足够</span></span><br><span class="line">    <span class="keyword">if</span> (argc &lt; <span class="number">2</span>) &#123;</span><br><span class="line">        std::cout &lt;&lt; argv[<span class="number">0</span>] &lt;&lt; <span class="string">&quot; xx.pcd -kn 50 -bc 0 -fc 10.0 -nc 0 -st 30 -ct 0.05&quot;</span> &lt;&lt; std::endl;</span><br><span class="line">        <span class="comment">// 提示用法：可指定法线邻域数、是否裁剪、远近裁剪距离、平滑/曲率阈值等</span></span><br><span class="line">        <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="type">time_t</span> start, end;                           <span class="comment">// 用于计时</span></span><br><span class="line">    start = <span class="built_in">time</span>(<span class="number">0</span>);</span><br><span class="line">    <span class="type">double</span> diff[<span class="number">3</span>] = &#123;<span class="number">0</span>&#125;;                        <span class="comment">// 存储三个阶段耗时：加载、法线、分割</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 默认参数设置</span></span><br><span class="line">    <span class="type">int</span> KN_normal = <span class="number">50</span>;                          <span class="comment">// 法线估计时使用的邻居点数</span></span><br><span class="line">    <span class="type">bool</span> Bool_Cuting = <span class="literal">false</span>;                    <span class="comment">// 是否启用 Z 方向裁剪</span></span><br><span class="line">    <span class="type">float</span> far_cuting = <span class="number">10.0f</span>, near_cuting = <span class="number">0.0f</span>; <span class="comment">// 裁剪范围：z ∈ [near_cuting, far_cuting]</span></span><br><span class="line">    <span class="type">float</span> SmoothnessThreshold = <span class="number">30.0f</span>;           <span class="comment">// 平滑角阈值（单位：度）</span></span><br><span class="line">    <span class="type">float</span> CurvatureThreshold = <span class="number">0.05f</span>;            <span class="comment">// 曲率阈值</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 解析命令行参数（如果用户提供）</span></span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-kn&quot;</span>, KN_normal); <span class="comment">// -kn: 法线邻居数</span></span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-bc&quot;</span>, Bool_Cuting); <span class="comment">// -bc: 是否裁剪（0/1）</span></span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-fc&quot;</span>, far_cuting);  <span class="comment">// -fc: 远裁剪平面</span></span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-nc&quot;</span>, near_cuting); <span class="comment">// -nc: 近裁剪平面</span></span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-st&quot;</span>, SmoothnessThreshold); <span class="comment">// -st: 平滑角阈值（度）</span></span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-ct&quot;</span>, CurvatureThreshold);  <span class="comment">// -ct: 曲率阈值</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 加载点云数据</span></span><br><span class="line">    pcl::PointCloud&lt;pcl::PointXYZ&gt;::<span class="function">Ptr <span class="title">cloud</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::PointXYZ&gt;)</span></span>;</span><br><span class="line">    <span class="keyword">if</span> (pcl::io::<span class="built_in">loadPCDFile</span>&lt;pcl::PointXYZ&gt;(argv[<span class="number">1</span>], *cloud) == <span class="number">-1</span>) &#123;</span><br><span class="line">        <span class="built_in">PCL_ERROR</span>(<span class="string">&quot;Cloud reading failed.\n&quot;</span>);    <span class="comment">// 加载失败报错</span></span><br><span class="line">        <span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    end = <span class="built_in">time</span>(<span class="number">0</span>);</span><br><span class="line">    diff[<span class="number">0</span>] = <span class="built_in">difftime</span>(end, start);              <span class="comment">// 计算加载耗时</span></span><br><span class="line">    <span class="built_in">PCL_INFO</span>(<span class="string">&quot;Loading pcd file takes (seconds): %.2f\n&quot;</span>, diff[<span class="number">0</span>]);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 法线估计</span></span><br><span class="line">    pcl::search::Search&lt;pcl::PointXYZ&gt;::<span class="function">Ptr <span class="title">tree</span><span class="params">(<span class="keyword">new</span> pcl::search::KdTree&lt;pcl::PointXYZ&gt;)</span></span>;</span><br><span class="line">    pcl::PointCloud&lt;pcl::Normal&gt;::<span class="function">Ptr <span class="title">normals</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::Normal&gt;)</span></span>;</span><br><span class="line">    pcl::NormalEstimation&lt;pcl::PointXYZ, pcl::Normal&gt; normal_estimator;</span><br><span class="line">    normal_estimator.<span class="built_in">setSearchMethod</span>(tree);      <span class="comment">// 设置搜索方法为 KdTree</span></span><br><span class="line">    normal_estimator.<span class="built_in">setInputCloud</span>(cloud);       <span class="comment">// 输入原始点云</span></span><br><span class="line">    normal_estimator.<span class="built_in">setKSearch</span>(KN_normal);      <span class="comment">// 使用 KN_normal 个最近邻估计法线</span></span><br><span class="line">    normal_estimator.<span class="built_in">compute</span>(*normals);          <span class="comment">// 计算法线并存储到 normals</span></span><br><span class="line">    end = <span class="built_in">time</span>(<span class="number">0</span>);</span><br><span class="line">    diff[<span class="number">1</span>] = <span class="built_in">difftime</span>(end, start) - diff[<span class="number">0</span>];    <span class="comment">// 计算法线估计耗时</span></span><br><span class="line">    <span class="built_in">PCL_INFO</span>(<span class="string">&quot;Estimating normal takes (seconds): %.2f\n&quot;</span>, diff[<span class="number">1</span>]);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 直通滤波（Z方向裁剪）</span></span><br><span class="line">    <span class="function">pcl::IndicesPtr <span class="title">indices</span><span class="params">(<span class="keyword">new</span> std::vector&lt;<span class="type">int</span>&gt;)</span></span>; <span class="comment">// 存储保留点的索引</span></span><br><span class="line">    <span class="keyword">if</span> (Bool_Cuting) &#123;</span><br><span class="line">        pcl::PassThrough&lt;pcl::PointXYZ&gt; pass;</span><br><span class="line">        pass.<span class="built_in">setInputCloud</span>(cloud);</span><br><span class="line">        pass.<span class="built_in">setFilterFieldName</span>(<span class="string">&quot;z&quot;</span>);             <span class="comment">// 对 z 坐标进行过滤</span></span><br><span class="line">        pass.<span class="built_in">setFilterLimits</span>(near_cuting, far_cuting); <span class="comment">// 设置裁剪区间</span></span><br><span class="line">        pass.<span class="built_in">filter</span>(*indices);                    <span class="comment">// 输出满足条件的点的索引</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 区域生长分割</span></span><br><span class="line">    pcl::RegionGrowing&lt;pcl::PointXYZ, pcl::Normal&gt; reg;</span><br><span class="line">    reg.<span class="built_in">setMinClusterSize</span>(<span class="number">50</span>);                   <span class="comment">// 每个聚类最小点数</span></span><br><span class="line">    reg.<span class="built_in">setMaxClusterSize</span>(<span class="number">1000000</span>);              <span class="comment">// 最大点数限制（防止过大）</span></span><br><span class="line">    reg.<span class="built_in">setSearchMethod</span>(tree);                   <span class="comment">// 使用 KdTree 加速搜索</span></span><br><span class="line">    reg.<span class="built_in">setNumberOfNeighbours</span>(<span class="number">30</span>);               <span class="comment">// 每个点考虑其 30 个最近邻</span></span><br><span class="line">    reg.<span class="built_in">setInputCloud</span>(cloud);                    <span class="comment">// 输入原始点云</span></span><br><span class="line">    <span class="keyword">if</span> (Bool_Cuting) reg.<span class="built_in">setIndices</span>(indices);    <span class="comment">// 如果启用了裁剪，则只在裁剪后的点上分割</span></span><br><span class="line">    reg.<span class="built_in">setInputNormals</span>(normals);                <span class="comment">// 输入法线信息（区域生长依赖法线）</span></span><br><span class="line">    reg.<span class="built_in">setSmoothnessThreshold</span>(SmoothnessThreshold / <span class="number">180.0</span> * M_PI); <span class="comment">// 转换为弧度</span></span><br><span class="line">    reg.<span class="built_in">setCurvatureThreshold</span>(CurvatureThreshold); <span class="comment">// 曲率阈值用于判断边界</span></span><br><span class="line"></span><br><span class="line">    std::vector&lt;pcl::PointIndices&gt; clusters;     <span class="comment">// 存储分割出的所有聚类</span></span><br><span class="line">    reg.<span class="built_in">extract</span>(clusters);                       <span class="comment">// 执行区域生长分割</span></span><br><span class="line">    end = <span class="built_in">time</span>(<span class="number">0</span>);</span><br><span class="line">    diff[<span class="number">2</span>] = <span class="built_in">difftime</span>(end, start) - diff[<span class="number">0</span>] - diff[<span class="number">1</span>]; <span class="comment">// 计算分割耗时</span></span><br><span class="line">    <span class="built_in">PCL_INFO</span>(<span class="string">&quot;Region growing takes (seconds): %.2f\n&quot;</span>, diff[<span class="number">2</span>]);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 输出聚类结果统计</span></span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;Number of clusters: &quot;</span> &lt;&lt; clusters.<span class="built_in">size</span>() &lt;&lt; std::endl;</span><br><span class="line">    <span class="keyword">if</span> (!clusters.<span class="built_in">empty</span>()) &#123;</span><br><span class="line">        std::cout &lt;&lt; <span class="string">&quot;First cluster has &quot;</span> &lt;&lt; clusters[<span class="number">0</span>].indices.<span class="built_in">size</span>() &lt;&lt; <span class="string">&quot; points.&quot;</span> &lt;&lt; std::endl;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 打印内存使用情况</span></span><br><span class="line">    <span class="built_in">PrintMemoryInfo</span>();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 可视化分割结果（彩色点云）</span></span><br><span class="line">    pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr colored_cloud = reg.<span class="built_in">getColoredCloud</span>();</span><br><span class="line">    pcl::<span class="function">visualization::CloudViewer <span class="title">viewer</span><span class="params">(<span class="string">&quot;PCL Region Growing Segmentation&quot;</span>)</span></span>;</span><br><span class="line">    viewer.<span class="built_in">showCloud</span>(colored_cloud);             <span class="comment">// 显示着色后的点云</span></span><br><span class="line">    <span class="keyword">while</span> (!viewer.<span class="built_in">wasStopped</span>()) &#123;</span><br><span class="line">        <span class="comment">// 等待用户关闭窗口</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>; <span class="comment">// 成功退出</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><img src="https://ckyfi9zero.github.io/picx-images-hosting/20250805/image.6iklrfp8cs.webp" alt="image"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io">Fi9zero</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io/2025/08/05/2025-08-05-%E5%9F%BA%E4%BA%8E%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E7%9A%84%E5%88%86%E5%89%B2/">https://ckyfi9zero.github.io/2025/08/05/2025-08-05-%E5%9F%BA%E4%BA%8E%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E7%9A%84%E5%88%86%E5%89%B2/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://ckyfi9zero.github.io" target="_blank">荒岛</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/c/">c++</a><a class="post-meta__tags" href="/tags/PCL/">PCL</a></div><div class="post-share"><div class="social-share" data-image="/image/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="pagination-related  no-desc" href="/2025/08/05/2025-08-05-%E5%9F%BA%E4%BA%8E%E9%A2%9C%E8%89%B2%E7%9A%84%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E5%88%86%E5%89%B2/" title="基于颜色的区域生长分割"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info"><div class="info-1"><div class="info-item-1">上一篇</div><div class="info-item-2">基于颜色的区域生长分割</div></div></div></a><a class="pagination-related  no-desc" href="/2025/08/05/2025-08-05-%E7%82%B9%E4%BA%91%E6%AC%A7%E5%BC%8F%E8%81%9A%E7%B1%BB%E6%8F%90%E5%8F%96/" title="点云欧式聚类提取"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-right"><div class="info-1"><div class="info-item-1">下一篇</div><div class="info-item-2">点云欧式聚类提取</div></div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8kdtree%E5%AE%9E%E7%8E%B0%E5%BF%AB%E9%80%9F%E9%A2%86%E5%9F%9F%E6%90%9C%E7%B4%A2/" title="用kdtree实现快速领域搜索"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用kdtree实现快速领域搜索</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E5%85%AB%E5%8F%89%E6%A0%91%E8%BF%9B%E8%A1%8C%E6%97%A0%E5%BA%8F%E7%82%B9%E4%BA%91%E6%95%B0%E6%8D%AE%E7%9A%84%E7%A9%BA%E9%97%B4%E5%8F%98%E5%8C%96%E6%A3%80%E6%B5%8B/" title="用八叉树进行无序点云数据的空间变化检测"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用八叉树进行无序点云数据的空间变化检测</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E7%9B%B4%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8%E5%AF%B9%E7%82%B9%E4%BA%91%E8%BF%9B%E8%A1%8C%E6%BB%A4%E6%B3%A2%E5%A4%84%E7%90%86/" title="用直通滤波器对点云进行滤波处理"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用直通滤波器对点云进行滤波处理</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E7%82%B9%E4%BA%91%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F/" title="从点云创建一个深度图像"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从点云创建一个深度图像</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E4%B8%80%E4%B8%AA%E7%82%B9%E4%BA%91%E4%B8%AD%E6%8F%90%E5%8F%96%E4%B8%80%E4%B8%AA%E5%AD%90%E9%9B%86/" title="从一个点云中提取一个子集"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从一个点云中提取一个子集</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E5%9C%A8%E6%BB%A4%E6%B3%A2%E5%99%A8%E6%A8%A1%E5%9D%97%E7%A7%BB%E9%99%A4%E7%A6%BB%E7%BE%A4%E7%82%B9/" title="在滤波器模块移除离群点"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">在滤波器模块移除离群点</div></div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">Fi9zero</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/ckyFi9zero"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/ckyFi9zero" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:2539894206@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9F%BA%E4%BA%8E%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E7%9A%84%E5%88%86%E5%89%B2"><span class="toc-number">1.</span> <span class="toc-text">基于区域生长的分割</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%A7%A9-%E4%B8%80%E3%80%81%E6%95%B4%E4%BD%93%E6%B5%81%E7%A8%8B%E6%A6%82%E8%BF%B0"><span class="toc-number">1.1.</span> <span class="toc-text">🧩 一、整体流程概述</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%94%A7-%E4%BA%8C%E3%80%81%E6%A0%B8%E5%BF%83%E6%A8%A1%E5%9D%97%E8%A7%A3%E6%9E%90"><span class="toc-number">1.2.</span> <span class="toc-text">🔧 二、核心模块解析</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E2%9A%99%EF%B8%8F-%E4%B8%89%E3%80%81%E5%85%B3%E9%94%AE%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E"><span class="toc-number">1.3.</span> <span class="toc-text">⚙️ 三、关键参数说明</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%93%88-%E5%9B%9B%E3%80%81%E6%80%A7%E8%83%BD%E7%9B%91%E6%8E%A7%E5%8A%9F%E8%83%BD"><span class="toc-number">1.4.</span> <span class="toc-text">📈 四、性能监控功能</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%8E%A8-%E4%BA%94%E3%80%81%E5%8F%AF%E8%A7%86%E5%8C%96%E7%89%B9%E7%82%B9"><span class="toc-number">1.5.</span> <span class="toc-text">🎨 五、可视化特点</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%8C%B1-%E5%85%AD%E3%80%81%E5%8C%BA%E5%9F%9F%E7%94%9F%E9%95%BF%E5%8E%9F%E7%90%86%E7%AE%80%E8%BF%B0"><span class="toc-number">1.6.</span> <span class="toc-text">🌱 六、区域生长原理简述</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%92%BE-%E4%B8%83%E3%80%81%E8%BE%93%E5%87%BA%E7%BB%93%E6%9E%9C"><span class="toc-number">1.7.</span> <span class="toc-text">💾 七、输出结果</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%9B%A0%EF%B8%8F-%E5%85%AB%E3%80%81%E5%8F%AF%E6%94%B9%E8%BF%9B%E6%96%B9%E5%90%91%EF%BC%88%E8%BF%9B%E9%98%B6%E5%BB%BA%E8%AE%AE%EF%BC%89"><span class="toc-number">1.8.</span> <span class="toc-text">🛠️ 八、可改进方向（进阶建议）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E2%9C%85-%E5%B8%A6%E8%AF%A6%E7%BB%86%E6%B3%A8%E9%87%8A%E7%9A%84%E4%BB%A3%E7%A0%81%EF%BC%88%E5%8F%B3%E4%BE%A7%E4%B8%BA%E8%A7%A3%E9%87%8A%EF%BC%89"><span class="toc-number">1.9.</span> <span class="toc-text">✅ 带详细注释的代码（右侧为解释）</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/10/05/2025-10-05-lio_sam/" title="lio_sam">lio_sam</a><time datetime="2025-10-05T02:43:51.000Z" title="发表于 2025-10-05 10:43:51">2025-10-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境">使用docker搭建pytorch环境</a><time datetime="2025-08-12T12:43:33.000Z" title="发表于 2025-08-12 20:43:33">2025-08-12</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-docker/" title="docker">docker</a><time datetime="2025-08-05T11:02:36.000Z" title="发表于 2025-08-05 19:02:36">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E8%BF%90%E5%8A%A8%E5%AF%B9%E8%B1%A1%E5%88%86%E5%89%B2%E4%B8%8E%E9%85%8D%E5%87%86%E7%AE%97%E6%B3%95/" title="运动对象分割与配准算法">运动对象分割与配准算法</a><time datetime="2025-08-05T08:16:02.000Z" title="发表于 2025-08-05 16:16:02">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E6%9D%A1%E4%BB%B6%E6%AC%A7%E5%BC%8F%E8%81%9A%E7%B1%BB%E5%88%86%E5%89%B2/" title="条件欧式聚类分割">条件欧式聚类分割</a><time datetime="2025-08-05T07:56:39.000Z" title="发表于 2025-08-05 15:56:39">2025-08-05</time></div></div></div></div></div></div></main><footer id="footer"><div class="footer-other"><div class="footer-copyright"><span class="copyright">&copy;&nbsp;2025 By Fi9zero</span><span class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo 7.3.0</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly 5.4.2</a></span></div><div class="footer_custom_text">Only light can attract bugs.</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"><script>(() => {
  const loadMathjax = () => {
    if (!window.MathJax) {
      window.MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']],
          tags: 'none',
        },
        chtml: {
          scale: 1.1
        },
        options: {
          enableMenu: true,
          renderActions: {
            findScript: [10, doc => {
              for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
                const display = !!node.type.match(/; *mode=display/)
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
                const text = document.createTextNode('')
                node.parentNode.replaceChild(text, node)
                math.start = {node: text, delim: '', n: 0}
                math.end = {node: text, delim: '', n: 0}
                doc.math.push(math)
              }
            }, '']
          }
        }
      }

      const script = document.createElement('script')
      script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
      script.id = 'MathJax-script'
      script.async = true
      document.head.appendChild(script)
    } else {
      MathJax.startup.document.state(0)
      MathJax.texReset()
      MathJax.typesetPromise()
    }
  }

  btf.addGlobalFn('encrypt', loadMathjax, 'mathjax')
  window.pjax ? loadMathjax() : window.addEventListener('load', loadMathjax)
})()</script><script>(() => {
  const runMermaid = ele => {
    window.loadMermaid = true
    const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

    ele.forEach((item, index) => {
      const mermaidSrc = item.firstElementChild
      const mermaidThemeConfig = `%%{init:{ 'theme':'${theme}'}}%%\n`
      const mermaidID = `mermaid-${index}`
      const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent

      const renderFn = mermaid.render(mermaidID, mermaidDefinition)
      const renderMermaid = svg => {
        mermaidSrc.insertAdjacentHTML('afterend', svg)
      }

      // mermaid v9 and v10 compatibility
      typeof renderFn === 'string' ? renderMermaid(renderFn) : renderFn.then(({ svg }) => renderMermaid(svg))
    })
  }

  const codeToMermaid = () => {
    const codeMermaidEle = document.querySelectorAll('pre > code.mermaid')
    if (codeMermaidEle.length === 0) return

    codeMermaidEle.forEach(ele => {
      const preEle = document.createElement('pre')
      preEle.className = 'mermaid-src'
      preEle.hidden = true
      preEle.textContent = ele.textContent
      const newEle = document.createElement('div')
      newEle.className = 'mermaid-wrap'
      newEle.appendChild(preEle)
      ele.parentNode.replaceWith(newEle)
    })
  }

  const loadMermaid = () => {
    if (true) codeToMermaid()
    const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
    if ($mermaid.length === 0) return

    const runMermaidFn = () => runMermaid($mermaid)
    btf.addGlobalFn('themeChange', runMermaidFn, 'mermaid')
    window.loadMermaid ? runMermaidFn() : btf.getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaidFn)
  }

  btf.addGlobalFn('encrypt', loadMermaid, 'mermaid')
  window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
})()</script></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/pig.js"></script><script src="/js/weather.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="text-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="站内搜索..." type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>